<?php
include_once 'userprofile.php';
include_once 'editprofile.php';
include_once 'dbconnect.php';

class Model
{
	public function makeListUser($result)
	{
		$ListUser = array();
		while($row = mysql_fetch_assoc($result)){
			$oneUser = new User();
			$oneUser->set($row['id'], $row['username'], $row['profile']);
			array_push($ListUser, $oneUser);
		}
		mysql_free_result($result);
		return $ListUser;
	}

	public function getAllUsers()
	{
		$query = "SELECT * FROM userprofile ";
		$result = mysql_query($query);
		return $this->makeListUser($result);
	}
	
	public function insertUserProfile($id, $username, $profile)
	{
		$query = "INSERT INTO userprofile(id, username, profile) VALUES (". $id .",". $username .",". $profile .")";
		$rsInsert = mysql_query($query);
		if($rsInsert == null){
			return false;
		}		
		else{
			return true;		
		}
	}
	

}
?>
